﻿using HelloLLLLL.Blog.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace HelloLLLLL.Blog.Models
{
    [PrimaryKey("Id")]
    public class Pinglun
    {
        public int Id { get; set; }
        public int ArtId { get; set; }
        public string ArtTitle { get; set; }

        public string Pubnisher { get; set; }

        public string Content
        {
            get { return content; }
            set
            {
                string ss = value.ToLower();

                int index1 = ss.IndexOf("<script>");

                int index2 = ss.IndexOf("<javascript>");
                while (index1 != -1 || index2 != -1)
                {
                    string script = "", script2 = "";
                    if (index1 != -1)
                    {
                        script = value.Substring(index1, 8);
                    }
                    if (index2 != -1)
                    {
                        script2 = value.Substring(index2, 8);
                    }

                    if (index1 != -1)
                    {
                        value.Replace(script, "<java脚本标记>");
                    }
                    if (index2 != -1)
                    {
                        value.Replace(script2, "<java脚本标记>");
                    }
                    ss = value.ToLower();
                    
                    index1 = ss.IndexOf("<script>");

                    index2 = ss.IndexOf("<javascript>");
                }

                content = value;

            }
        }

        private string content;

        public DateTime PubnishTime { get; set; }

        public string Email { get; set; }

        public string Home { get; set; }

        public string  VisSystem{ get; set; }
        public string VisSoft { get; set; }
        [LLNoMap()]
        public string CTime { get { return PubnishTime.ToString(); } }

        public int ReplyId { get; set; }

        [LLNoMap()]
        public List<Pinglun> ChildPL { get; set; }


    }

    [PrimaryKey("Id")]
    public class LeaveMessage
    {
        public int Id { get; set; }

        public string Pubnisher { get; set; }

        public string Content
        {
            get { return content; }
            set
            {
                string ss = value.ToLower();

                int index1 = ss.IndexOf("<script>");

                int index2 = ss.IndexOf("<javascript>");
                while (index1 != -1 || index2 != -1)
                {
                    string script = "", script2 = "";
                    if (index1 != -1)
                    {
                        script = value.Substring(index1, 8);
                    }
                    if (index2 != -1)
                    {
                        script2 = value.Substring(index2, 8);
                    }

                    if (index1 != -1)
                    {
                        value.Replace(script, "<java脚本标记>");
                    }
                    if (index2 != -1)
                    {
                        value.Replace(script2, "<java脚本标记>");
                    }
                    ss = value.ToLower();

                    index1 = ss.IndexOf("<script>");

                    index2 = ss.IndexOf("<javascript>");
                }

                content = value;

            }
        }

        private string content;

        public DateTime PubnishTime { get; set; }

        public string Email { get; set; }

        public string Home { get; set; }

        public string VisSystem { get; set; }
        public string VisSoft { get; set; }
        [LLNoMap()]
        public string CTime { get { return PubnishTime.ToString(); } }

        public int ReplyId { get; set; }

        [LLNoMap()]
        public List<LeaveMessage> ChildPL { get; set; }


    }

}
